package shun.demo.curve;

import android.graphics.Path;
import shun.demo.common.logger.Log;

/**
 * Created by chen on 3/21/14.
 */
public class SineCurve {

    private float mPoints[];
    private Path mPath;

    public void sample(int T) {
        mPoints = new float[T * 2];
        mPath = new Path();
        for (int i = 0; i < T; i++) {
            mPoints[i*2 + 0] = i;
            mPoints[i*2 + 1] = -(float) (100.0 * Math.sin(((2 * Math.PI) / T) * i));
            mPath.lineTo(mPoints[i*2 + 0], mPoints[i*2 + 1]);
        }
    }

    public Path asPath() {
        return mPath;
    }

    public float[] asPoints() {
        return mPoints;
    }

    public void dump() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < mPoints.length; i += 2) {
            Log.v("SineCurve", "[" + mPoints[i] + "," + mPoints[i+1] + "]");
        }
    }
}
